﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Interactivity;
using Microsoft.Phone.Controls;

namespace PhoneToolkit.Extensions.Behaviors
{
    public class TransitionSlideInBehavior : Behavior<PhoneApplicationPage>
    {
        protected override void OnAttached()
        {
            base.OnAttached();

            NavigationInTransition navInTrans = new NavigationInTransition();
            navInTrans.Backward = new SlideTransition() { Mode = TransitionModeBackwardIn };
            navInTrans.Forward = new SlideTransition() { Mode = TransitionModeForwardIn };
            TransitionService.SetNavigationInTransition(this.AssociatedObject, navInTrans);
        }

        protected override void OnDetaching()
        {
            base.OnDetaching();
        }

        public static readonly DependencyProperty TransitionModeBackwardInProperty = DependencyProperty.Register("TransitionModeSlideBackWardIn", typeof(SlideTransitionMode), typeof(TransitionSlideInBehavior), new PropertyMetadata(SlideTransitionMode.SlideRightFadeIn));
        public static readonly DependencyProperty TransitionModeForwardInProperty = DependencyProperty.Register("TransitionModeSlideForwardIn", typeof(SlideTransitionMode), typeof(TransitionSlideInBehavior), new PropertyMetadata(SlideTransitionMode.SlideLeftFadeIn));

        public SlideTransitionMode TransitionModeBackwardIn
        {
            get { return (SlideTransitionMode)GetValue(TransitionModeBackwardInProperty); }
            set { SetValue(TransitionModeBackwardInProperty, value); }
        }

        public SlideTransitionMode TransitionModeForwardIn
        {
            get { return (SlideTransitionMode)GetValue(TransitionModeForwardInProperty); }
            set { SetValue(TransitionModeForwardInProperty, value); }
        }
    }
}
